<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>广联达宜比木-登录</title>
	<link rel="stylesheet" type="text/css" href="/lib/bootstrap/3.3.7/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="/css/base.css">
	<link rel="stylesheet" type="text/css" href="/css/login.css">
</head>
<body>
	<!--logo-->
	<div class="container">
		<h1 class="logo">
			<img src="/image/login/logo-2.png" alt="">
		</h1>
	</div>
	<!--主体-->
	<form style="position:relative;" class="bg" id="formlogin">
		<div class="bg-img">
			
		</div>
		<div class="login">
				<h4 class="title">用户登录</h4>
				<div class="input-group">
					<label for="user"><span class="glyphicon glyphicon-user"></span></label>
					<input type="text" class="form-control"  name="username" id="loginname" placeholder="邮箱/用户名" />
				</div>
				<div class="input-group">
					<label for="pwd"><span class="glyphicon glyphicon-lock"></span></label>
					<input type="password" class="form-control" name="password" id="nloginpwd"  placeholder="请输入您的密码" />
				</div>
				<input type="button" class="btn btn-primary" id="loginsubmit" value="登录" />
				<a href="javascript:;" class="btn btn-default" id="glodonlogin">广联云登录</a>
				<p style="bottom: 18%;text-align: center;left: 0;width: 100%;color: red;">
					<%
						if(request.getParameter("error")!=null){
					%>
						用户名或密码错误		
					<%	}
					%>
				</p> 
				<p>
					<a href="https://account.glodon.com/forgetInit" target="_blank">忘记密码?</a><span>|</span><a href="https://account.glodon.com/register" target="_blank">注册</a>
				</p>
			</div>
	</form>
	<!--网站信息-->
	<div class="info container">
		<span>Copyright&copy;1998-2015广联达科技有限股份公司</span> <span>京ICP备10021606号</span>
		<span>京公网安备110108401054号</span>
	</div>
	<script type="text/javascript" src="/lib/jquery/1.11.2/jquery.min.js"></script>
	<script type="text/javascript" src="/lib/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="/lib/jquery.validate/jquery.validate.min.js"></script>
	<script type="text/javascript" src="/lib/jquery-form/jquery.form.js"></script>
	
	    <script type="text/javascript">
    var redirectUrl = "${redirect}";
	var LOGIN = {
			checkInput:function() {
				if ($("#loginname").val() == "") {
					alert("用户名不能为空");
					$("#loginname").focus();
					return false;
				}
				if ($("#nloginpwd").val() == "") {
					alert("密码不能为空");
					$("#nloginpwd").focus();
					return false;
				}
				return true;
			},
			doLogin:function() {
				$.post("/account/login", $("#formlogin").serialize(),function(data){
					if (data.status == 200) {
						alert("登录成功！");
						if (redirectUrl == "") {
							location.href = "${pageContext.request.contextPath}/page/success";
						} else {
							location.href = redirectUrl;
						}
					} else {
						alert("登录失败，原因是：" + data.msg);
						$("#loginname").select();
					}
				});
			},
			login:function() {
				if (this.checkInput()) {
					this.doLogin();
				}
			}
		
	};
	$(function(){
		//普通登录方式
		$("#loginsubmit").click(function(){
			LOGIN.login();
		});
		
		//广联云登录
		$("#glodonlogin").click(function(){
			location.href="https://account.glodon.com/oauth2/authorize?response_type=code&client_id=CkHorSCQuBQwNhgHiKgvPPNWsYYprmXj&redirect_uri=http://localhost:8080/account/userLoginByGlodon?redirect="+redirectUrl;
		});
	});
    </script>
	
</body>
</html>